<template>
	<div class="container">
		<div class="header">
			<div style="display: flex;align-items: center;">
				<label>第</label>
				<a-pagination v-model:current="currentWeekNum" simple :total="200" />
				<label>周</label>
			</div>
			<div class="week">
				<div></div>
				<div v-for="day in week">{{ day }}</div>
			</div>
		</div>
		<div style="height: 70vh;
	display: flex;
	flex-direction: column;
	justify-content: space-around;
	align-items: center;">
			<div class="row">
				<div class="cell time">
					<div> 8:20 </div>
					<div> ~ </div>
					<div> 9:55 </div>
				</div>
				<div class="cell" v-for="(course, index) in course_table[0]" :key="index">{{ course }}</div>
			</div>
			<div class="row">
				<div class="cell time">
					<div> 10:15 </div>
					<div> ~ </div>
					<div> 11:50 </div>
				</div>
				<div class="cell" v-for="(course, index) in course_table[1]" :key="index">{{ course }}</div>
			</div>
			<el-divider content-position="center" style="margin: 16px auto;">午餐</el-divider>
			<div class="row">
				<div class="cell time">
					<div> 14:30 </div>
					<div> ~ </div>
					<div> 16:05 </div>
				</div>
				<div class="cell" v-for="(course, index) in course_table[2]" :key="index">{{ course }}</div>
			</div>
			<div class="row">
				<div class="cell time">
					<div> 16:25 </div>
					<div> ~ </div>
					<div> 18:00 </div>
				</div>
				<div class="cell" v-for="(course, index) in course_table[3]" :key="index">{{ course }}</div>
			</div>
			<el-divider content-position="center" style="margin: 16px auto;">晚餐</el-divider>
			<div class="row">
				<div class="cell time">
					<div> 19:00 </div>
					<div> ~ </div>
					<div> 21:25 </div>
				</div>
				<div class="cell" v-for="(course, index) in course_table[3]" :key="index">{{ course }}</div>
			</div>
		</div>
	</div>
</template>
<script setup>
import { ref, watch } from 'vue';
import axios from 'axios';
const currentWeekNum = ref(16);
const week = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日']

const course_table = ref([])

axios(
	{
		method: 'get',
		url: '/course',
		headers: {
			'toten': localStorage.getItem('token')
		},
		params: {
			classId: 1,  // 班级id
			weekNum: currentWeekNum.value,  // 周数
		}
	}
).then(
	res => {
		course_table.value = JSON.parse(res.data.data.oneWeekCourse)
	}
)


watch(
	currentWeekNum, () => {
		axios(
			{
				method: 'get',
				url: '/course',
				headers: {
					'toten': localStorage.getItem('token')
				},
				params: {
					classId: 1,  // 班级id
					weekNum: currentWeekNum.value,  // 周数
				}
			}
		).then(
			res => {
				course_table.value = JSON.parse(res.data.data.oneWeekCourse)
			}
		)
	}
);



</script>
<style scoped>
.container {
	height: 84vh;
	width: 65vw;
	margin: 0 auto;
	border-radius: 5px;
	box-shadow: 3px 1px 20px 0 rgba(0, 0, 0, 0.4);
	background-color: #c2c1af;
}

.header {
	height: 15%;
	width: inherit;
	display: flex;
	flex-direction: column;
	justify-content: space-around;
	align-items: center;
}

.header>.week {
	width: inherit;
	display: flex;
	justify-content: space-around;
	align-items: center;
}

.header>.week>div {
	width: 10%;
	height: inherit;
	text-align: center;
}

.cell {
	width: 10%;
	height: 90%;
	display: inline-block;
	border-radius: 5px;
	padding: 2px;
	font-size: 15px;
	border: 0.1px solid;
}

.cell:hover {
	background-color: rgba(255, 255, 255, 0.2);
	backdrop-filter: blur(5px);
	box-shadow: 1px 1px 2px 1px rgba(0, 0, 0, 0.4),
		inset 1px 1px 1px 2px rgba(253, 254, 253, 0.3);
	border: 0;
}

.time {
	display: flex;
	flex-direction: column;
	justify-content: space-around;
	align-items: center;
}

.row {
	height: 19%;
	width: 100%;
	display: flex;
	justify-content: space-around;
	align-items: center;
}
</style>